package dk.itu.iwjx.helper;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * regular expression example
 * http://www.dreamincode.net/forums/blog/324/entry-2676-password-validation-in-java-via-regex/
 * @author li
 *
 */
public class Validation {

	public boolean validateEmail(String email){
	      //Set the email pattern string
	      Pattern p = Pattern.compile(".+@.+\\.[a-z]+");

	      //Match the given string with the pattern
	      Matcher m = p.matcher(email);

	      //check whether match is found 
	      boolean matchFound = m.matches();

		return matchFound;
	}
	public boolean validatePhone(int phone){
		if(phone>=10000000 && phone<=99999999)
			 return true;
		return false;
	}
	public boolean validateZipcode(int zipcode){
		if(zipcode>=1000 && zipcode<=9999)
			 return true;
		return false;
	}
	
	public boolean validatePassword(String password){		 		  
	      //Set the pass pattern string
		   // at least 1 digit, 1 low case, 1 upper case 
	      Pattern p = Pattern.compile("((?=.*\\d)(?=.*[a-zA-Z])(?=.*\\W).{6,12})");

	      //Match the given string with the pattern
	      Matcher m = p.matcher(password);

	      //check whether match is found 
	      boolean matchFound = m.matches();

		return matchFound;
	}
	
	public boolean validateName(String name){

        // check unique of name
		return true;
	}
}
